package com.adv.ems.manager.impl;

import com.adv.ems.db.mapper.UserMapper;
import com.adv.ems.db.entity.UserDO;
import com.adv.ems.manager.UserManager;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Optional;

@Service
public class UserManagerImpl extends BaseManagerImpl<UserMapper, UserDO> implements UserManager {
    @Override
    public UserDO getUserByUsername(String username) {
        Map<Long, UserDO> allMap = getAllMap();
        Optional<UserDO> first = allMap
                .values()
                .stream()
                .filter(u -> username.equals(u.getUserName()))
                .findFirst();
        return first.orElse(null);
    }
}
